﻿using System;
using System.ServiceModel;
using Crowler.Model.CoreComponents;

namespace Crowler.Dispatcher.Api.Di
{
    public class MyServiceHost: ServiceHost 
    {
        public MyServiceHost() 
        {
            
        }

        public MyServiceHost(IAppEnvironment dependency, Type serviceType, params Uri[] baseAddresses)
            : base(serviceType, baseAddresses)
        {
            if (dependency == null)
            {
                throw new ArgumentNullException("dependency");
            }

            foreach (var cd in this.ImplementedContracts.Values)
            {
                cd.Behaviors.Add(new MyInstanceProvider(dependency));
            }  
        }

        
    }
}
